package net.webservicex;

import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.xml.sax.InputSource;

public class CdataToXmlReader {
	public static Document loadXMLFromString(String xmlString) throws Exception {

//		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//		InputSource source = new InputSource(new StringReader(xml));
//		Document document = factory.newDocumentBuilder().parse(source);
//		return document;
		
		Document doc = null;
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        factory.setNamespaceAware(false);
        DocumentBuilder builder = factory.newDocumentBuilder();
        doc = builder.parse(new InputSource(new StringReader(xmlString)));
        System.out.println(doc.getDocumentElement().getNodeName());
        return doc;
	}
}
